package com.nut.spp.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.nut.spp.common.BaseEntity;
import lombok.Data;

import java.util.List;

/**
 * 商品表
 */
@Data
@TableName("biz_goods")
public class Goods extends BaseEntity {

    private Integer id;

    //标题
    private String title;

    //封面图
    private String img;

    //NC编码
    private String ncCode;

    //条形码
    private String barCode;

    //价格 分
    private Integer price;

    //售卖价格 分
    private Integer salePrice;

    //会员价格 分
    private Integer memberPrice;

    //商品类型 1买会员 2粉丝代理套餐（会员和非会员） 3单商品 4商品套组
    private Integer type;

    //排序 排序值越大越靠前
    private Integer sort;

    //状态 0初始 1已下架 2已上架
    private Integer status;

    //非会员粉丝代理佣金 分
    private Integer proxy;

    //会员粉丝代理佣金 分
    private Integer memberProxy;

    //代理公司佣金 分
    private Integer companyProxy;

    //师傅公司佣金 分
    private Integer parentProxy;

    //是否需要送货 1是 0否
    private Integer freight;

    //轮播图
    @TableField(exist = false)
    private String slider;

    //内容
    @TableField(exist = false)
    private String content;

    //商品组合
    @TableField(exist = false)
    private List<GoodsCompose> composeList;

    public GoodsDetail getGoodsDetail() {
        GoodsDetail goodsDetail = new GoodsDetail();
        goodsDetail.setId(id);
        goodsDetail.setSlider(this.slider);
        goodsDetail.setContent(this.content);
        return goodsDetail;
    }

    public boolean needUpdate() {
        return this.title != null ||
                this.img != null ||
                this.price != null ||
                this.salePrice != null ||
                this.memberPrice != null ||
                this.type != null ||
                this.sort != null ||
                this.status != null;

    }

    public boolean needUpdateDetail() {
        return this.slider != null ||
                this.content != null;
    }

}
